package fr.ece.ing4.inf442.cours2;

public class DemoSleep {
	public static void main(String[] args) throws InterruptedException {
		Thread myThread = new Thread() {
			@Override
			public void run() {
				int c = 0;
				while (!isInterrupted()) {
					System.out.println(c++ + ": Hello world !");
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						break;
					}
				}
				System.out.println(c + ": Interrupted !");
			}
		};
		myThread.start();
		Thread.sleep(5000);
		myThread.interrupt();
	}
}
